﻿using StarPizza.Model.BaseModel;
using StarPizza.ViewModel.Core;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace StarPizza.ViewModel.ClientSystem
{
    abstract class PizzaOrderer : INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;
        protected void OnPropertyChanged(string propertyName)
        {
            if (this.PropertyChanged != null)
            {
                this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }

        OrderController orderController;
        DoughLister doughLister;
        protected DoughVM SelectedDoughVM { get { return doughLister.SelectedIngredientVM; } }
        public PizzaOrderer(OrderController orderController, DoughLister doughLister)
        {
            this.orderController = orderController;
            this.doughLister = doughLister;
        }
        protected void OrderPizza(IPizzaTemplate pizzaTemplate)
        {
            var pizza = PreparePizzaVMBase();
            pizza.PizzaTemplate = pizzaTemplate;
            orderController.AddPizza(pizza);
        }
        protected PizzaVM PreparePizzaVMBase()
        {
            return new PizzaVM
            {
                Dough = this.SelectedDoughVM.WrappedDough
            };
        }
    }
}
